package mysale.service.impl;

import mysale.dao.UserDao;
import mysale.dao.impl.UserDaoImpl;
import mysale.pojo.User;
import mysale.service.UserService;
import mysale.util.JDBCUtil;

import java.sql.Connection;

/**
 * @author SnakeWoodMan
 * @create 2020-12-25 11:04
 */
public class UserServiceImpl implements UserService {
    private Connection conn = JDBCUtil.getConnection();
    private UserDaoImpl userDao = new UserDaoImpl(conn);

    public User login(String userName, String password) {
        User user = userDao.getUserByUserNameAndPassword(userName, password);
//        JDBCUtil.close(conn);
        return user;
    }

    public  boolean regist(User user) {
        boolean result = userDao.insertUser(user);
//        DBUtil.close(conn);
        return result;
    }
}
